package fileupload

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
)

func Upload(c *gin.Context) {
	file, _ := c.FormFile("file")
	log.Println(file.Filename)
	c.SaveUploadedFile(file, file.Filename)
	c.String(200, fmt.Sprintf("'%s' 已经上传！", file.Filename))

}

func Goupload(c *gin.Context) {
	c.HTML(200, "uploadfile.html", nil)
}

func Test1() {
	e := gin.Default()
	e.LoadHTMLGlob("fileupload/*")
	e.MaxMultipartMemory = 8 << 20
	e.POST("/upload", Upload)
	e.GET("/upload", Goupload)
	e.Run(":9999")

}
